package com.example.javaword;

import com.deepoove.poi.XWPFTemplate;
import com.deepoove.poi.data.Texts;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.HashMap;

/**
 * @author 41081
 */
public class TextSimpleDemo1 {
    public static void main(String[] args) throws IOException {
        XWPFTemplate template = XWPFTemplate.compile(Consts.PATH + "template.docx").render(
                new HashMap<String, Object>(4) {{
                    put("title", "Hi, poi-tl Word模板引擎");
                    put("redOne", Texts.of("红色字").color("c75662").create());
                    put("link", Texts.of("超链接").link("http://deepoove.com").create());
                    put("anchor", Texts.of("锚点").anchor("appendix1").create());
                }});
        template.writeAndClose(Files.newOutputStream(Paths.get(Consts.PATH + "output.docx")));
    }
}
